package cate.game.play.buff.h;

import cate.common.util.XT;
import cate.game.play.base.HpCfg;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;

import java.util.List;

/**
 * 获得最大生命值*28%的护盾，持续时间结束或被清除对敌方全体造成8%最大生命值的伤害
 *
 * 强化效果1：持续时间结束或者被清除时提升自身7%伤害减免(不可驱散)
 */
public class 觉醒盾爆BH extends 护盾BH {

	private HpCfg 伤害配置;

	@Override
	public void parse(String code) {
		super.parse(code);
		伤害配置 = new HpCfg(new PlayCfgArgs(code),"伤害配置");
	}

	private List<Integer> 移除添加buff;

	@Override
	public void parseExt(String code) {
		super.parseExt(code);
		PlayCfgArgs args = new PlayCfgArgs(code);
		移除添加buff = args.getIntList("移除添加buff");
	}

	@Override
	public void onInvalid(ActionCtx action, byte invalidReason) {
		super.onInvalid(action, invalidReason);
		TargetFilterParam param = new TargetFilterParam().targetNumSet(6);
		for (Fighter fighter : TargetSelector.doFind(buff.owner, action.getTeamVs(), param)) {
			double damage = 伤害配置.settle(buff.owner, fighter);
			fighter.attr.buffHurt(action, buff.owner, damage);
		}
		if (XT.isNotBlank(移除添加buff)) {
			for (Integer integer : 移除添加buff) {
				buff.owner.buff.tryAddByTid(action, integer);
			}
		}
	}
}
